package com.grom.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

public class SqlFileUtil {

	public static List<String> getSqlsFromFile(String fileName) throws IOException {
		InputStream input = SqlFileUtil.class.getClassLoader().getResourceAsStream(fileName);
		BufferedReader reader = new BufferedReader(new InputStreamReader(input));
		String data;
		String result = "";
		while ((data = reader.readLine()) != null) {
			result += data;
		}
		System.out.println(result);
		String[] tmp = result.split(";");
		return Arrays.asList(tmp);
	}

	public static void main(String[] args) {
		try {
			List<String> sqlList = getSqlsFromFile("init_all.sql");
			for(String sql : sqlList){
				System.out.println(sql);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
